package com.dongan;

import org.junit.jupiter.api.Test;

/**
 * @ClassName:bb
 * @Description:
 * @Author:longtao
 * @Date:2021/6/30
 * @Version:1.0
 */
public class bb {
    public static void main(String[] args) {
        int [] arr={-11,-10,-5,-1,0,5,6,7,8,9,13,15,65};
        int a=65;
        int head=0;
        int end=arr.length-1;
       // int i=(head+end)/2;
        while (head<=end){
            int i=(head+end)/2;
            System.out.println("i = " + i);
            if (arr[i]==a){
                System.out.println("二分查找已经找到值了,索引为:"+i);
                break;
            }else if (arr[i]>a){
                end=i-1;
            }else if (arr[i]<a){
                head=i+1;
            }
           // head++;
        }
    }


    @Test
    public void bubbleSortTest(){
        int [] arr={66,98,-5,-6,3,0,-4,-89,10,52,32,79,56,12,36,-99};
        int [] arr2={0,-2,6,9,5};
        //-2,0,6,5,9//循环4次
        //-2,0,5,6,9//循环3次
        for (int i = 0; i < arr.length-1; i++) {
            for (int j = 0; j < arr.length-i-1; j++) {
                if (arr[j]>arr[j+1]){
                    int a=arr[j];
                    arr[j]=arr[j+1];
                    arr[j+1]=a;
                }
            }
        }

        for (int i : arr) {
            System.out.print(i+"\t");
        }
    }


    @Test
    public void  test(){
        cc c=new cc();
        c.test();
        System.out.println(c instanceof aa);
    }

    @Test
    public void test2(){
        cc c=new cc();
        c.test();
    }
}
